package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PwDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos = new FileOutputStream("pw.txt");
        OutputStreamWriter ows = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bos = new BufferedWriter(ows);
        PrintWriter pw = new PrintWriter(bos);
        Scanner sc = new Scanner(System.in);
        System.out.println("请开始输入内容,单独按exit时结束");
        while (true){
            String str = sc.nextLine();
            if ("exit".equals(str)){
                pw.write(str);
                break;
            }
            pw.println(str);

        }
        System.out.println("再见");
        pw.close();
    }
}
